{% extends theme('base.html') %}
{% block list_bar %}
    <nav class="navbar container bg-danger" role="navigation">
        <div class="navbar-header">
            <a class="navbar-brand">分类 </a>
        </div>
        <div class="collapse navbar-collapse">
            <ul class="nav nav-tabs navbar-nav" role="tablist" id="ctgtab">
                {% for c in category %}
                    {% if request.url.find(c.name+'/')>=0 %}
                        <li role="presentation" class="active">
                            <a href="{{ url_for('main.index',categoryname=c.name,month=month,page=1) }}">{{ c.name }}</a>
                        </li>
                    {% else %}
                        <li role="presentation">
                            <a href="{{ url_for('main.index',categoryname=c.name,month=month,page=1) }}">{{ c.name }}</a>
                        </li>
                    {% endif %}
                {% endfor %}

            </ul>
            <form class="nav navbar-nav navbar-form navbar-right" action="{{ url_for('main.search') }}" method="POST"
                  role="search">
                {{ g.search_form.hidden_tag() }}
                <div class="form-group">
                    {{ g.search_form.search(class="form-control" ,placeholder="搜索本站") }}
                </div>
                <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span>搜索
                </button>
            </form>
        </div>
    </nav>
    <br/>
{% endblock %}
{% block content %}
    <div class=" container">
        <div class=" pull-left" style="width: 70%;float: left">
            {% for art in article.items %}
                <div class="panel panel-info  ">
                    <div class="panel-heading text-left">
                        <h4><a href="{{ url_for('article.show',aid = art.id) }}">{{ art.title }}</a>
                            {% if g.user.is_authenticated() and g.user.is_admin() %}
                                <div class="pull-right">
                                    <a class="btn btn-lg btn-round" data-trigger="tooltip" data-content="编辑此文"
                                       data-position="e"
                                       title="点击编辑"
                                       href="{{ url_for('article.edit',id=art.id) }}"><i
                                            class="glyphicon glyphicon-edit red"></i></a>
                                </div>
                            {% endif %}
                        </h4>
                    </div>
                    <div class="panel-body text-left">
                        <h5>{{ art.text[:200]+'...' }}</h5>
                    </div>
                    <div class="panel-footer panel-warning text-left">
                        <h6>标签:
                            {% for t in art.tag.split(' ') %}
                                <a data-trigger="tooltip" data-content="更多关于 {{ t }}" data-position="e"
                                   href="{{ url_for('main.search_result', sch=t, page=1) }}"> {{ t }} </a>
                            {% endfor %}
                            <div class="pull-right ">
                                <small class="h6 text-muted">
                                    评论：<span class="badge">{{ comment_times(art.id) }}</span>
                                    阅读：<span class="badge">{{ art.numlook }}</span>
                                    时间：{{ art.timestamp }}
                                </small>
                            </div>
                        </h6>
                    </div>
                </div>
            {% endfor %}
            <div class="text-left">
                <ul class="pager">
                    {% if article.has_prev %}
                        <li class="previous">
                            <a href="{{ url_for('main.index', categoryname=categoryname,month=month,page = article.prev_num) }}">&larr;
                                Newer</a>
                        </li>
                    {% else %}
                        <li class="previous disabled">
                            <a>&larr; Newer</a>
                        </li>
                    {% endif %}
                    第{{ article.page }}页/共{{ article.pages }}页
                    {% if article.has_next %}
                        <li class="next"><a
                                href="{{ url_for('main.index', categoryname=categoryname,month=month,page = article.next_num) }}">Older &rarr;</a>
                        </li>
                    {% else %}
                        <li class="next disabled"><a>Older &rarr;</a></li>
                    {% endif %}
                </ul>
            </div>
        </div>

        <div class=" pull-right" style="width: 20%">
            <div class="row spacer-bottom10">
                <div class="col-md-12">
                    <div class="panel panel-primary">
                        <div class="panel-heading ">
                            <img class="img-circle" alt="Responsive image" src="{{ admin_img }}"/>
                            博主：{{ admin_name }}
                            </a>
                        </div>
                        <div class="panel-body">
                            <div class="panel-footer"
                                 style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
                                个性签名：{{ admin_info }}</div>
                            <div class="panel-footer"
                                 style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
                                联系方式：<a target="_blank"
                                        href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=uoKNjo2PjIyNjvrLy5TZ1dc"
                                        style="text-decoration:none;"><img
                                    src="http://rescdn.qqmail.com/zh_CN/htmledition/images/function/qm_open/ico_mailme_01.png"/></a><br/>
                            </div>
                        </div>
                    </div>
                </div>
                {% if g.user.is_authenticated() %}
                    <div class="col-md-12">
                        <div class="panel panel-success">
                            <div class="panel-heading ">
                                <a href="http://www.gravatar.com/" target="_blank">
                                    <img class="img-circle" alt="Responsive image" src="{{ g.user.avatar(30) }}"
                                         title="点击编辑图像"/>
                                </a>
                                昵称：
                                <a class="btn btn-sm btn-default" href="{{ url_for('user.usereditinfo') }}"
                                   title="点击编辑个人信息"> {{ g.user.nicename }}
                                </a>
                            </div>
                            <div class="panel-body">
                                <div class="panel-footer"
                                     style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
                                    个性签名：{{ g.user.info }}</div>
                                <div class="panel-footer"
                                     style="overflow: hidden; text-overflow: ellipsis; white-space: nowrap;">
                                    上次离开：{{ g.user.last_seen }}</div>
                            </div>
                        </div>
                    </div>
                {% endif %}
                <div class="col-md-12">
                    <div class="panel panel-success">
                        <div class="panel-heading">阅读排行：</div>
                        <div class="panel-body text-left">
                            {% for art in top_ten %}
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>&nbsp
                                <a href="{{ url_for('article.show', aid=art.id) }}">
                                    {{ art.title[:12] }}&nbsp&nbsp <span
                                        class="badge pull-right"> {{ art.numlook }}</span>
                                </a><br/>
                            {% endfor %}
                        </div>
                    </div>
                </div>
                {% cache 10 %}
                    <div class="col-md-12">
                        <div class="panel panel-success">
                            <div class="panel-heading">时间线：</div>
                            <div class="panel-body text-left">
                                {% for ct in month_count %}
                                    <span class="glyphicon glyphicon-circle-arrow-right"></span>&nbsp
                                    <a href="{{ url_for('main.index', categoryname=categoryname,month=ct.months,page = 1) }}">
                                        {{ ct.months }}&nbsp&nbsp <span
                                            class="badge badge-success pull-right"> {{ ct.num }}</span>
                                    </a><br/>
                                {% endfor %}
                            </div>
                        </div>
                    </div>
                    <div class="col-md-12">
                        <div class="panel panel-success">
                            <div class="panel-heading">最新评论：</div>
                            <ul class="list-group">
                                {% for nc in ten_comments %}
                                    <li class="list-group-item">
                                        {% if nc.author is not none %}
                                            <img class="img-thumbnail"
                                                 src="{{ nc.author.avatar(15) }}">
                                            {% if nc.article ==0 %}
                                                {{ nc.name }}
                                                <a href="{{ url_for('main.msg') }}">留言</a>
                                            {% else %}
                                                {{ nc.name }} 评论
                                                <a href="{{ url_for('article.show',aid=nc.article_id) }}">{{ nc.article.title }}</a>
                                            {% endif %}
                                            :<br>
                                            {{ nc.comment }}
                                        {% else %}

                                            {% if nc.article_id ==0 or nc.article_id==none %}
                                                {{ nc.name }}
                                                <a href="{{ url_for('main.msg') }}">留言</a>
                                            {% else %}
                                                {{ nc.name }} 评论
                                                <a href="{{ url_for('article.show',aid=nc.article_id) }}">{{ nc.article.title }}</a>
                                            {% endif %}
                                            :<br>
                                            {{ nc.comment }}
                                        {% endif %}
                                    </li>
                                {% endfor %}
                            </ul>

                        </div>
                    </div>
                    <br/>

                    <div class="col-md-12 ">
                        <div class="panel panel-default">
                            <div class="panel-heading">本站统计：</div>
                            <div class="panel-body text-left">
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                日访问量：<span class=" pull-right">{{ visit_day }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                月访问量：<span class=" pull-right">{{ visit_month }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                总访问量：<span class=" pull-right">{{ visit_all }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                文章总数：<span class=" pull-right">{{ article_all }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                本月新增：<span class=" pull-right">{{ article_month }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                日评论数：<span class=" pull-right">{{ comment_day }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                月评论数：<span class=" pull-right">{{ comment_month }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                总评论数：<span class=" pull-right">{{ comment_all }}</span>
                                <br/>

                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                用户数量：<span class=" pull-right">{{ user_all }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                登陆次数：<span class=" pull-right">{{ login_all }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                恶意访问：<span class=" pull-right">{{ visit_attack }}</span>
                                <br/>
                                <span class="glyphicon glyphicon-circle-arrow-right"></span>
                                爬虫访问：<span class="pull-right">{{ visit_robot }}</span>
                                <br/>

                            </div>
                        </div>
                    </div>
                {% endcache %}
            </div>
        </div>
    </div>
{% endblock %}